package top.songxs.gmall.common.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.songxs.gmall.common.properties.MinioProperties;
import top.songxs.gmall.common.service.FileUploadService;

@Configuration
@EnableConfigurationProperties(value = MinioProperties.class)
public class FileUploadConfig {
    @Autowired
    private MinioProperties pro;

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(pro.getEndpoint())
                .credentials(pro.getAccessKey(), pro.getSecretKey())
                .build();
    }

    @Bean
    public FileUploadService fileUploadService(){
        return new FileUploadService();
    }
}
